'''
Created on 07/06/2010

@author: Will
'''
from pyglet import window 
from pyglet import clock 


class GameWindow(window.Window):

    def __init__(self, *args, **kwargs):
        window.Window.__init__(self, *args, **kwargs)
        self.set_mouse_visible(True)
        self.set_size(800,600)
        self.mouseHandlers = []
        
        clock.set_fps_limit(60)
        print "window set up"



    """******************************************
    Event Handlers
    *********************************************"""
    def on_mouse_motion(self, x, y, dx, dy):
        for i in self.mouseHandlers:
            i.on_mouse_motion(x,y,dx,dy)
        self.mousePos = (x,y)   

    def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
        for i in self.mouseHandlers:
            i.on_mouse_drag( x, y, dx, dy, buttons, modifiers)        

    def on_mouse_press(self, x, y, button, modifiers):
        for i in self.mouseHandlers:
            i.on_mouse_press(x,y,button,modifiers)

    def on_mouse_scroll(self,x, y, scroll_x, scroll_y):
        for i in self.mouseHandlers:
            i.on_mouse_scroll(x,y,scroll_x,scroll_y)

    def notifyMouseEventsTo(self, asker):
        self.mouseHandlers.append(asker)

